#pragma once

#include "SearchExcelPage.g.h"
#include <stack>
#include <winrt/Microsoft.UI.Xaml.Controls.h>
#include <filesystem>


namespace winrt::GMTK::implementation
{

    struct SearchExcelPage : SearchExcelPageT<SearchExcelPage>
    {
        SearchExcelPage()
        {
            // Xaml objects should not call InitializeComponent during construction.
            // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
        }

        int32_t MyProperty();
        void MyProperty(int32_t value);

        winrt::Microsoft::UI::Xaml::Visibility ConvertVisibility(bool visible);
        void SearchBtnClick(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
        void OffenUseBtnClick(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
        void OnLoad(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
        void InitProgComboBox();
        void ComboBox_SearchProj_SelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Controls::SelectionChangedEventArgs const& e);
        void SetSearching(bool searching);
        void CancelOngoingSearch();
        void ShowEmptyHintIfNeeded(int resultCount);

    private:
        std::stack<winrt::Microsoft::UI::Xaml::Controls::StackPanel> m_StackPanelCache;

    private:

        void LoadOffenUse();
		void DisplaySearchResults(std::filesystem::path searchRoot, std::vector<winrt::hstring>& result, bool isSearch);
        winrt::Microsoft::UI::Xaml::Controls::StackPanel CreateItemFromTemplate();
        void DisplayItem(const winrt::hstring& name, const winrt::Microsoft::UI::Xaml::Controls::StackPanel& item, int childIx, bool isSearch);

    };
}

namespace winrt::GMTK::factory_implementation
{
    struct SearchExcelPage : SearchExcelPageT<SearchExcelPage, implementation::SearchExcelPage>
    {
    };
}
